
Public Class Form1

    Public oldv1 As Integer
    Public newv1 As Integer
    Public newh1 As Integer

    Public vcode() As Integer
    Public hcode() As Integer

    Public buttonname1() As String
    Public buttonname2() As String

    Public auto1 As Integer
    Public auto2 As Integer
    Public auto3 As Integer
    Public auto4 As Integer
    Public auto5 As Integer
    Public auto6 As Integer
    Public auto7 As Integer

    Public press As Integer

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        HookKeyboard()
        TextBox1.Text = "Start"

        'MsgBox(ComboBox1.SelectedIndex)
        'MsgBox(ComboBox2.SelectedIndex)


    End Sub

    Public Sub New()

        ' This call is required by the Windows Form Designer.
        InitializeComponent()

        ' Add any initialization after the InitializeComponent() call.

        vcode = New Integer() {&H0, &H0, &H1, &H3, &H4, &H8, &H9, &HC, &HD, &H10, &H11, &H12, &H13, _
         &H14, &H1B, &H20, &H21, &H22, &H23, &H24, &H25, &H26, &H27, &H28, &H29, &H2A, &H2B, _
         &H2C, &H2D, &H2E, &H2F, &H30, &H31, &H32, &H33, &H34, &H35, &H36, &H37, &H38, &H39, _
         &H41, &H42, &H43, &H44, &H45, &H46, &H47, &H48, &H49, &H4A, &H4B, &H4C, &H4D, &H4E, _
         &H4F, &H50, &H51, &H52, &H53, &H54, &H55, &H56, &H57, &H58, &H59, &H5A, &H60, &H61, _
         &H62, &H63, &H64, &H65, &H66, &H67, &H68, &H69, &H6C, &H6D, &H6E, &H6F, &H70, &H71, _
         &H72, &H73, &H74, &H75, &H76, &H77, &H78, &H79, &H7A, &H7B, &H7C, &H7D, &H7E, &H7F, _
         &H80, &H81, &H82, &H83, &H84, &H85, &H86, &H87, &H90, &H91, &HA0, &HA1, &HA2, &HA3, _
         &HA4, &HA5, &HFA, &HFB, &H5B, &H5C, &H5D, &H5F}

        auto1 = 0
        auto2 = 0
        auto3 = 0
        auto4 = 0
        auto5 = 0
        auto6 = 0
        auto7 = 0
        Timer1.Start()
        TextBox2.Text = 100
        TextBox3.Text = 100

        buttonname1 = New String() {"", "Invalid key1     ", "Invalid key2      ", "Invalid key3            ", "Invalid key4                            ", "BACKSPACE key", "TAB key", "CLEAR key", "ENTER key", "Invalid key5", "Invalid key6", "Invalid key7", "PAUSE key", "CAPS LOCK key", "ESC key", "SPACEBAR", "PAGE UP key", "PAGE DOWN key", "END key", "HOME key", "LEFT ARROW key", "UP ARROW key", "RIGHT ARROW key", "DOWN ARROW key", "SELECT key", "PRINT key", "EXECUTE key", "PRINT SCREEN key", "INS key", "DEL key", "HELP key", "0 key", "1 key", "2 key", "3 key", "4 key", "5 key", "6 key", "7 key", "8 key", "9 key", "A key", "B key", "C key", "D key", "E key", "F key", "G key", "H key", "I key", "J key", "K key", "L key", "M key", "N key", "O key", "P key", "Q key", "R key", "S key", "T key", "U key", "V key", "W key", "X key", "Y key", "Z key", "Numeric keypad 0 key", "Numeric keypad 1 key", "Numeric keypad 2 key", "Numeric keypad 3 key", "Numeric keypad 4 key", "Numeric keypad 5 key", "Numeric keypad 6 key", "Numeric keypad 7 key", "Numeric keypad 8 key", "Numeric keypad 9 key", "Separator key", "Subtract key", "Decimal key", "Divide key", "F1 key", "F2 key", "F3 key", "F4 key", "F5 key", "F6 key", "F7 key", "F8 key", "F9 key", "F10 key", "F11 key", "F12 key", "F13 key", "F14 key", "F15 key", "F16 key", "F17 key", "F18 key", "F19 key", "F20 key", "F21 key", "F22 key", "F23 key", "F24 key", "NUM LOCK key", "SCROLL LOCK key", "Left SHIFT key", "Right SHIFT key", "Left CONTROL key", "Right CONTROL key", "Left MENU key", "Right MENU key", "Play key", "Zoom key", "Left Win Key", "Right Win Key", "Applications Key", "Sleep Key"}
        buttonname2 = New String() {"", "Left mouse button", "Right mouse button", "Control-break processing", "Middle mouse button (three-button mouse)", "BACKSPACE key", "TAB key", "CLEAR key", "ENTER key", "SHIFT key   ", "CTRL key    ", "ALT key     ", "PAUSE key", "CAPS LOCK key", "ESC key", "SPACEBAR", "PAGE UP key", "PAGE DOWN key", "END key", "HOME key", "LEFT ARROW key", "UP ARROW key", "RIGHT ARROW key", "DOWN ARROW key", "SELECT key", "PRINT key", "EXECUTE key", "PRINT SCREEN key", "INS key", "DEL key", "HELP key", "0 key", "1 key", "2 key", "3 key", "4 key", "5 key", "6 key", "7 key", "8 key", "9 key", "A key", "B key", "C key", "D key", "E key", "F key", "G key", "H key", "I key", "J key", "K key", "L key", "M key", "N key", "O key", "P key", "Q key", "R key", "S key", "T key", "U key", "V key", "W key", "X key", "Y key", "Z key", "Numeric keypad 0 key", "Numeric keypad 1 key", "Numeric keypad 2 key", "Numeric keypad 3 key", "Numeric keypad 4 key", "Numeric keypad 5 key", "Numeric keypad 6 key", "Numeric keypad 7 key", "Numeric keypad 8 key", "Numeric keypad 9 key", "Separator key", "Subtract key", "Decimal key", "Divide key", "F1 key", "F2 key", "F3 key", "F4 key", "F5 key", "F6 key", "F7 key", "F8 key", "F9 key", "F10 key", "F11 key", "F12 key", "F13 key", "F14 key", "F15 key", "F16 key", "F17 key", "F18 key", "F19 key", "F20 key", "F21 key", "F22 key", "F23 key", "F24 key", "NUM LOCK key", "SCROLL LOCK key", "Left SHIFT key", "Right SHIFT key", "Left CONTROL key", "Right CONTROL key", "Left MENU key", "Right MENU key", "Play key", "Zoom key", "Left Win Key", "Right Win Key", "Applications Key", "Sleep Key"}
        ComboBox1.Items.Clear()
        ComboBox2.Items.Clear()
        ComboBox3.Items.Clear()
        ComboBox4.Items.Clear()
        ComboBox5.Items.Clear()
        ComboBox6.Items.Clear()
        ComboBox7.Items.Clear()
        ComboBox8.Items.Clear()
        ComboBox9.Items.Clear()
        ComboBox10.Items.Clear()
        ComboBox11.Items.Clear()
        ComboBox12.Items.Clear()
        ComboBox13.Items.Clear()
        ComboBox14.Items.Clear()
        For i As Integer = 0 To buttonname1.Length - 1
            ComboBox1.Items.Add(buttonname1(i))
            ComboBox3.Items.Add(buttonname1(i))
            ComboBox5.Items.Add(buttonname1(i))
            ComboBox7.Items.Add(buttonname1(i))
            ComboBox9.Items.Add(buttonname1(i))
            ComboBox11.Items.Add(buttonname1(i))
            ComboBox13.Items.Add(buttonname1(i))
        Next
        For i As Integer = 0 To buttonname2.Length - 1
            ComboBox2.Items.Add(buttonname2(i))
            ComboBox4.Items.Add(buttonname2(i))
            ComboBox6.Items.Add(buttonname2(i))
            ComboBox8.Items.Add(buttonname2(i))
            ComboBox10.Items.Add(buttonname2(i))
            ComboBox12.Items.Add(buttonname2(i))
            ComboBox14.Items.Add(buttonname2(i))
        Next

        ComboBox1.SelectedIndex = 15
        ComboBox2.SelectedIndex = 10
        ComboBox3.SelectedIndex = 0
        ComboBox4.SelectedIndex = 0
        ComboBox5.SelectedIndex = 0
        ComboBox6.SelectedIndex = 0
        ComboBox7.SelectedIndex = 0
        ComboBox8.SelectedIndex = 0
        ComboBox9.SelectedIndex = 0
        ComboBox10.SelectedIndex = 0
        ComboBox11.SelectedIndex = 0
        ComboBox12.SelectedIndex = 0
        ComboBox13.SelectedIndex = 0
        ComboBox14.SelectedIndex = 0


        'hcode = New Integer() {&H0, &H0, &H0, &H0, &HE, &HF, &H0, &HD, &H10, &H11, &H12, &H13, _
        ' &H14, &H1B, &H20, &H21, &H22, &H23, &H24, &H25, &H26, &H27, &H28, &H29, &H2A, &H2B, _
        ' &H2C, &H2D, &H2E, &H2F, &H30, &H31, &H32, &H33, &H34, &H35, &H36, &H37, &H38, &H39, _
        ' &H41, &H42, &H43, &H44, &H45, &H46, &H47, &H48, &H49, &H4A, &H4B, &H4C, &H4D, &H4E, _
        ' &H4F, &H50, &H51, &H52, &H53, &H54, &H55, &H56, &H57, &H58, &H59, &H5A, &H60, &H61, _
        ' &H62, &H63, &H64, &H65, &H66, &H67, &H68, &H69, &H6C, &H6D, &H6E, &H6F, &H70, &H71, _
        ' &H72, &H73, &H74, &H75, &H76, &H77, &H78, &H79, &H7A, &H7B, &H7C, &H7D, &H7E, &H7F, _
        ' &H80, &H81, &H82, &H83, &H84, &H85, &H86, &H87, &H90, &H91, &HA0, &HA1, &HA2, &HA3, _
        ' &HA4, &HA5, &HFA, &HFB}

    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        UnhookKeyboard()
        TextBox1.Text = "Stop"
    End Sub

    Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
        UnhookKeyboard()
    End Sub

    Private Sub Timer1_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        If auto1 = 1 Then
            Keyboard.presskey(1)
        End If
        If auto2 = 1 Then
            Keyboard.presskey(2)
        End If
        If auto3 = 1 Then
            Keyboard.presskey(3)
        End If
        If auto4 = 1 Then
            Keyboard.presskey(4)
        End If
        If auto5 = 1 Then
            Keyboard.presskey(5)
        End If
        If auto6 = 1 Then
            Keyboard.presskey(6)
        End If
        If auto7 = 1 Then
            Keyboard.presskey(7)
        End If
    End Sub

    Private Sub CheckBox1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles CheckBox1.Click
        If CheckBox1.Checked = False Then
            auto1 = 0
        ElseIf CheckBox2.Checked = False Then
            auto2 = 0
        ElseIf CheckBox3.Checked = False Then
            auto3 = 0
        ElseIf CheckBox4.Checked = False Then
            auto4 = 0
        ElseIf CheckBox5.Checked = False Then
            auto5 = 0
        ElseIf CheckBox6.Checked = False Then
            auto6 = 0
        ElseIf CheckBox6.Checked = False Then
            auto7 = 0
        End If
    End Sub

    Private Sub TextBox2_LostFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox2.LostFocus
        If TextBox2.Text > 0 And TextBox2.Text < 100000 Then
            Timer1.Interval = TextBox2.Text
        End If
    End Sub

    Private Sub CheckBox2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles CheckBox2.Click
        If CheckBox2.Checked = False Then
            auto2 = 0
        End If
    End Sub

    Private Sub CheckBox3_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles CheckBox3.Click
        If CheckBox3.Checked = False Then
            auto3 = 0
        End If
    End Sub

    Private Sub CheckBox4_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles CheckBox4.Click
        If CheckBox4.Checked = False Then
            auto4 = 0
        End If
    End Sub

    Private Sub CheckBox5_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles CheckBox5.Click
        If CheckBox5.Checked = False Then
            auto5 = 0
        End If
    End Sub

    Private Sub CheckBox6_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles CheckBox6.Click
        If CheckBox6.Checked = False Then
            auto6 = 0
        End If
    End Sub

    Private Sub CheckBox7_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles CheckBox7.Click
        If CheckBox7.Checked = False Then
            auto7 = 0
        End If
    End Sub
End Class
